package Get4;

use Moose;
use HTML::TreeBuilder;

sub lookdown {
    my ( $name, %params ) = @_;
    my $lookdown = delete $params{lookdown};
    has $name => (
        %params,
        lazy    => 1,
        default => sub { $_[0]->tree->lookdown(@$lookdown) }
    );
}

has file => (
    is      => 'rw',
    default => 'file.html'
);

has tree => (
    is         => 'rw',
    lazy_build => 1
);

sub _build_tree {
    my ($self) = @_;
    HTML::TreeBuilder->new_from_file( $self->file );
}

lookdown name => (
    is        => 'ro',
    look_down => [ id => 'name' ],
);

lookdown w => (
    is        => 'ro',
    look_down => [ id => qr/w.lc.me/ ],
);

1;

package main;

my $o = Get4->new;

warn $o->w->as_HTML;

1;
